const path = require("path");
const json5 = require("json5");
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  mode:'development',
  entry:"index.js",
  output: {
    path:path.resolve(__dirname, "dist"),
    filename:"bundle.js",
    // 自动清理
    clean:true,
  },
  module:{
    rules:[
      // 支持css解析
      {
        test:/\.(css|scss|less)$/,
        use:["style-loader","css-loader"]
      },
      // 支持parse5解析
      {
        test:/\.json$/,
        type:"json",
        parser:{
          parse:json5.parse
        }
      }
    ]
  },
  plugins:[
    // 自动生成html
    new HtmlWebpackPlugin({
      title:"webpack management"
    })
  ],
  // yarn dev调用服务器开发
  devServer:{
    static:"./dist"
  }
}